<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_formget/model')->方法名();
*/
namespace jy_formget;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function yibaotype(){
		$yibaotype=str_array($this->setting['yibaotype'],'|');
		return $yibaotype;
	}
	public function shenfentype(){
		$shenfentype=str_array($this->setting['shenfentype'],'|');
		return $shenfentype;
	}
    public function checkcode($idcard)
    {
        $idcard = strtoupper($idcard);
        if (!preg_match('#^\d{17}(\d|X)$#', $idcard)) {

            return false;
        }
        // 判断出生年月日的合法性(解决号码为666666666666666666也能通过校验的问题)
        $birth = substr($idcard, 6, 8);
        if ($birth < "19000101" || $birth > date("Ymd")) {
            return false;
        }
        $year = substr($birth, 0, 4);
        $month = substr($birth, 4, 2);
        $day = substr($birth, 6, 2);
        if (!checkdate($month, $day, $year)) {
            return false;
        }
        // 校验身份证格式(mod11-2)
        $check_sum = 0;
        for ($i = 0; $i < 17; $i++) {
            // $factor = (1 << (17 - $i)) % 11;
            $check_sum += $idcard[$i] * ((1 << (17 - $i)) % 11);
        }
        $check_code = (12 - $check_sum % 11) % 11;
        $check_code = $check_code == 10 ? 'X' : strval($check_code);
        if ($check_code !== substr($idcard, -1)) {
            //return false;
        }
        return true;
    }
	public function minzus(){
		$date=array(
			'0'=>'保密',
			'1'=>'汉族',
			'2'=>'回族',
			'3'=>'满族',
			'4'=>'维吾尔族',
			'5'=>'苗族',
			'6'=>'彝族',
			'7'=>'土家族',
			'8'=>'藏族',
			'9'=>'蒙古族',
			'10'=>'侗族',
			'11'=>'布依族',
			'12'=>'瑶族',
			'13'=>'白族',
			'14'=>'朝鲜族',
			'15'=>'哈尼族',
			'16'=>'黎族',
			'17'=>'哈萨克族',
			'18'=>'傣族',
			'19'=>'畲族',
			'20'=>'傈僳族',
			'21'=>'东乡族',
			'22'=>'仡佬族',
			'23'=>'拉祜族',
			'24'=>'佤族',
			'25'=>'水族',
			'26'=>'纳西族',
			'27'=>'羌族',
			'28'=>'土族',
			'29'=>'仫佬族',
			'30'=>'锡伯族',
			'31'=>'柯尔克孜族',
			'32'=>'景颇族',
			'33'=>'达斡尔族',
			'34'=>'撒拉族',
			'35'=>'布朗族',
			'36'=>'毛南族',
			'37'=>'塔吉克族',
			'38'=>'普米族',
			'39'=>'阿昌族',
			'40'=>'怒族',
			'41'=>'鄂温克族',
			'42'=>'京族',
			'43'=>'基诺族',
			'44'=>'德昂族',
			'45'=>'保安族',
			'46'=>'俄罗斯族',
			'47'=>'裕固族',
			'48'=>'乌孜别克族',
			'49'=>'门巴族',
			'50'=>'鄂伦春族',
			'51'=>'独龙族',
			'52'=>'赫哲族',
			'53'=>'高山族',
			'54'=>'珞巴族',
			'55'=>'塔塔尔族',
		);
		return $date;
	}
}
?>